<template>
  <template v-for="(item, index) in router" :key="index">
    <el-sub-menu v-if="item.children" :index="item.path">
      <template #title>
        <el-icon>
          <component :is="item.meta?.icon"></component>
        </el-icon>
        <span>{{ item.meta?.title }}</span>
      </template>
      <Menu :router="item.children"></Menu>
    </el-sub-menu>
    <el-menu-item v-else :index="item.path">
      <el-icon>
        <component :is="item.meta?.icon"></component>
      </el-icon>
      <span>{{ item.meta?.title }}</span>
    </el-menu-item>
  </template>
</template>

<script lang="ts" setup>
import { ref, defineProps } from 'vue'
import type { RouteRecordRaw } from 'vue-router'
import Menu from '@/components/Menu/index.vue'
defineProps<{ router: RouteRecordRaw[] }>()
</script>
<style scoped></style>
